#include <rid.h>
#include <stdio.h>

#include <fn85.h>
#include <rid_fn85.h>

int
parse_arg_id(Rid user_id, const char *arg)
{
	size_t len;

	switch (rid_fn85_parse(user_id, arg, &len)) {
	case FN85_OKAY:
		return 0;
	case FN85_INVALID:
		fprintf(stderr,
			"Something wasn't a digit at index %zu in "
			"the user id.\n",
			len);
		break;
	case FN85_TOO_HIGH:
		fprintf(stderr,
			"Number became larger than possible at index %zu "
			"in the user id.\n",
			len);
		break;
	}

	return -1;
}

int
main(int argc, char *argv[])
{
	Rid id;
	int i = 0;

	if (argc < 2)
		rid_set(id, NULL);
	else if (parse_arg_id(id, argv[1]) < 0)
		return 1;

	for (; i < sizeof(id) - 1; ++i)
		printf("%i, ", id[i]);

	printf("%i\n", id[i]);
	return 0;
}
